--
-- Author: yawei.zhu
-- Date: 2018-10-18 15:27:49
--
-- PvpDynastyView
--
local IconRender = require("app.widget.renders.IconRender")

local fileName = string.getModeName(...)
local ClassRef = class(fileName, app.mvc.ViewBase)

ClassRef.VIEW_ROOT_RES = Res.PvpDynastyScene

function ClassRef:init()
	self._ui.Button_close:addClickEventListener(function()
		self:closeView()
	end)

	self._iconRenders = {}
	for i = 1, 3 do
		local render = IconRender.create(self._ui["icon_"..i])
		render:setTipEnable(true)
		self._iconRenders[i] = render
	end
end


function ClassRef:refresh(str, itemDatas)
	if not itemDatas then itemDatas = {} end
	
	display.setNodesMiddle(self._ui.Panel, self._ui.tips_img, self._ui.tips_2)
	self._ui.tips_1:setString(str)

	local intervalX = 112
	local offsetX = 38
	local midX = 255
	local midNum = (#itemDatas + 1) / 2
	for i = 1, 3 do
		local render = self._iconRenders[i]
		local data = itemDatas[i]
		if data then
			render:setVisible(true)
			render:setData(data)
			render:setPositionX(midX - (midNum - i) * intervalX - offsetX)
		else
			render:setVisible(false)
		end
	end
end

return ClassRef
